package jltx.fragmentpageframework.wetchat.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

import cn.jltx.support.SupportFragment;

/**
 * @author jltxseo
 *         Created by junlintianxia on 2017/06/20.
 */

public class WetChatTabPagerAdapter extends FragmentPagerAdapter{
    private List<TabFragmentInfo> fragmentList;

    public WetChatTabPagerAdapter(FragmentManager fm, List<TabFragmentInfo> fragmentList) {
        super(fm);
        this.fragmentList = fragmentList;
    }

    public List<TabFragmentInfo> getFragmentList() {
        return fragmentList;
    }

    public void setFragmentList(List<TabFragmentInfo> fragmentList) {
        this.fragmentList = fragmentList;
    }

    @Override
    public Fragment getItem(int position) {
        if(fragmentList != null){
            return fragmentList.get(position).fragment;
        }
        return null;
    }

    @Override
    public int getCount() {
        int count = 0;
        if(fragmentList != null){
            count = fragmentList.size();
        }
        return count;
    }

    public static class TabFragmentInfo{
        public String tabTile;
        public int tabPos;
        public SupportFragment fragment;

        public TabFragmentInfo(SupportFragment fragment,String tabTile, int tabPos) {
            this.tabTile = tabTile;
            this.tabPos = tabPos;
            this.fragment = fragment;
        }
    }
}
